#include <stdio.h>
#include <iostream>
#include <complex>

#include <chrono>
using namespace std;
typedef chrono::high_resolution_clock Clock;

#define MAXN 1000000000

void func0(complex<double> x[], complex<double> tmp0[], complex<double> I)
{
    int index0 = 0;
    int index1 = 9;
    for (size_t i = 0; i < 3; i++) {
        tmp0[i] = x[i] + I * x[index1];
        index1++;
    }
    index0 = 3;
    index1 = 6;
    for (size_t i = 0; i < 3; i++) {
        tmp0[index0] = x[index0] + I * x[index1];
        index0++;
        index1++;
    }
}

void func1(complex<double> x[], complex<double> tmp0[], complex<double> I)
{
    double *y = (double *) x;
    double *tmp1 = (double *) tmp0;
    int index0 = 0;
    int index1 = 9 * 2;
    for (size_t i = 0; i < 3; i++) {
        tmp1[index0 + 0] = y[index0 + 0] - y[index1 + 1];
        tmp1[index0 + 1] = y[index0 + 1] + y[index1 + 0];
        tmp1[index0 + 2] = y[index0 + 2] - y[index1 + 3];
        tmp1[index0 + 3] = y[index0 + 3] + y[index1 + 2];
        tmp1[index0 + 4] = y[index0 + 4] - y[index1 + 5];
        tmp1[index0 + 5] = y[index0 + 5] + y[index1 + 4];
    }
    index0 = 3 * 2;
    index1 = 6 * 2;
    for (size_t i = 0; i < 3; i++) {
        tmp1[index0 + 0] = y[index0 + 0] - y[index1 + 1];
        tmp1[index0 + 1] = y[index0 + 1] + y[index1 + 0];
        tmp1[index0 + 2] = y[index0 + 2] - y[index1 + 3];
        tmp1[index0 + 3] = y[index0 + 3] + y[index1 + 2];
        tmp1[index0 + 4] = y[index0 + 4] - y[index1 + 5];
        tmp1[index0 + 5] = y[index0 + 5] + y[index1 + 4];
    }
}

int main()
{
    complex<double> x[12];
    complex<double> y[12];
    complex<double> tmp0[12];
    complex<double> tmp1[12];
    complex<double> I = {0, 1};
    for (size_t i = 0; i < 12; i++) {
        x[i].real(i + 2 + (i + 1) * 0.5);
        x[i].imag(i + 3 + (i + 1) * 0.5);
        y[i].real(i + 2 + (i + 1) * 0.5);
        y[i].imag(i + 3 + (i + 1) * 0.5);
    }

    auto startTime = Clock::now();
    for (size_t i = 0; i < MAXN; i++) {
        func0(x, tmp0, I);
        func0(tmp0, x, I);
    }
    auto endTime = Clock::now();
    auto compTime0 = chrono::duration_cast<chrono::microseconds>(endTime - startTime);
    cout << compTime0.count() << endl;

    startTime = Clock::now();
    for (size_t i = 0; i < MAXN; i++) {
        func1(y, tmp1, I);
        func1(tmp1, y, I);
    }
    endTime = Clock::now();
    compTime0 = chrono::duration_cast<chrono::microseconds>(endTime - startTime);
    cout << compTime0.count() << endl;

    for (size_t i = 0; i < 6; i++)
        cout << tmp0[i] << endl;
    cout << endl;
    for (size_t i = 0; i < 6; i++)
        cout << tmp1[i] << endl;
}